package com.csdj.t309.papermanage.service;

import com.csdj.t309.papermanage.entity.User;
import com.csdj.t309.papermanage.entity.UserExample;
import com.csdj.t309.papermanage.mapper.UserMapper;
import com.csdj.t309.papermanage.util.Md5Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserService {
    @Resource
    private UserMapper userMapper;

    public User login(String account, String password) {
        String pwd = new Md5Utils().md5(password);
        UserExample userExample = new UserExample();
        userExample.createCriteria().andUsercodeEqualTo(account)
                .andUserpasswordEqualTo(pwd);
        List<User> list = userMapper.selectByExample(userExample);
        System.out.println("size:"+list.size());
        if(list != null && list.size()>0 ){
            System.out.println("==登录成功==");
            return list.get(0);
        }
        System.out.println("< 登录失败 >");
        return null;
    }


}
